import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/fund_list_model.dart';

FundListModel $FundListModelFromJson(Map<String, dynamic> json) {
  final FundListModel fundListModel = FundListModel();
  final List<FundModel>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<FundModel>(e) as FundModel).toList();
  if (data != null) {
    fundListModel.data = data;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    fundListModel.total = total;
  }
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    fundListModel.count = count;
  }
  final int? perPage = jsonConvert.convert<int>(json['per_page']);
  if (perPage != null) {
    fundListModel.perPage = perPage;
  }
  final int? currentPage = jsonConvert.convert<int>(json['current_page']);
  if (currentPage != null) {
    fundListModel.currentPage = currentPage;
  }
  final int? totalPages = jsonConvert.convert<int>(json['total_pages']);
  if (totalPages != null) {
    fundListModel.totalPages = totalPages;
  }
  return fundListModel;
}

Map<String, dynamic> $FundListModelToJson(FundListModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  data['total'] = entity.total;
  data['count'] = entity.count;
  data['per_page'] = entity.perPage;
  data['current_page'] = entity.currentPage;
  data['total_pages'] = entity.totalPages;
  return data;
}

extension FundListModelExtension on FundListModel {
  FundListModel copyWith({
    List<FundModel>? data,
    int? total,
    int? count,
    int? perPage,
    int? currentPage,
    int? totalPages,
  }) {
    return FundListModel()
      ..data = data ?? this.data
      ..total = total ?? this.total
      ..count = count ?? this.count
      ..perPage = perPage ?? this.perPage
      ..currentPage = currentPage ?? this.currentPage
      ..totalPages = totalPages ?? this.totalPages;
  }
}

FundModel $FundModelFromJson(Map<String, dynamic> json) {
  final FundModel fundModel = FundModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    fundModel.id = id;
  }
  final int? userId = jsonConvert.convert<int>(json['user_id']);
  if (userId != null) {
    fundModel.userId = userId;
  }
  final int? amount = jsonConvert.convert<int>(json['amount']);
  if (amount != null) {
    fundModel.amount = amount;
  }
  final int? currentAmount = jsonConvert.convert<int>(json['current_amount']);
  if (currentAmount != null) {
    fundModel.currentAmount = currentAmount;
  }
  final String? reason = jsonConvert.convert<String>(json['reason']);
  if (reason != null) {
    fundModel.reason = reason;
  }
  final int? orderId = jsonConvert.convert<int>(json['order_id']);
  if (orderId != null) {
    fundModel.orderId = orderId;
  }
  final int? withdrawalId = jsonConvert.convert<int>(json['withdrawal_id']);
  if (withdrawalId != null) {
    fundModel.withdrawalId = withdrawalId;
  }
  final WithdrawalModel? withdrawal = jsonConvert.convert<WithdrawalModel>(json['withdrawal']);
  if (withdrawal != null) {
    fundModel.withdrawal = withdrawal;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    fundModel.createdAt = createdAt;
  }
  final String? showTime = jsonConvert.convert<String>(json['showTime']);
  if (showTime != null) {
    fundModel.showTime = showTime;
  }
  return fundModel;
}

Map<String, dynamic> $FundModelToJson(FundModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['user_id'] = entity.userId;
  data['amount'] = entity.amount;
  data['current_amount'] = entity.currentAmount;
  data['reason'] = entity.reason;
  data['order_id'] = entity.orderId;
  data['withdrawal_id'] = entity.withdrawalId;
  data['withdrawal'] = entity.withdrawal?.toJson();
  data['created_at'] = entity.createdAt;
  data['showTime'] = entity.showTime;
  return data;
}

extension FundModelExtension on FundModel {
  FundModel copyWith({
    int? id,
    int? userId,
    int? amount,
    int? currentAmount,
    String? reason,
    int? orderId,
    int? withdrawalId,
    WithdrawalModel? withdrawal,
    String? createdAt,
    String? showTime,
  }) {
    return FundModel()
      ..id = id ?? this.id
      ..userId = userId ?? this.userId
      ..amount = amount ?? this.amount
      ..currentAmount = currentAmount ?? this.currentAmount
      ..reason = reason ?? this.reason
      ..orderId = orderId ?? this.orderId
      ..withdrawalId = withdrawalId ?? this.withdrawalId
      ..withdrawal = withdrawal ?? this.withdrawal
      ..createdAt = createdAt ?? this.createdAt
      ..showTime = showTime ?? this.showTime;
  }
}

WithdrawalModel $WithdrawalModelFromJson(Map<String, dynamic> json) {
  final WithdrawalModel withdrawalModel = WithdrawalModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    withdrawalModel.id = id;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    withdrawalModel.status = status;
  }
  return withdrawalModel;
}

Map<String, dynamic> $WithdrawalModelToJson(WithdrawalModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['status'] = entity.status;
  return data;
}

extension WithdrawalModelExtension on WithdrawalModel {
  WithdrawalModel copyWith({
    int? id,
    int? status,
  }) {
    return WithdrawalModel()
      ..id = id ?? this.id
      ..status = status ?? this.status;
  }
}